package com.health.tablebean.webservice;

import android.content.Context;
import android.text.TextUtils;

import com.health.db.FDbManager;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.CD_TUBERCULOSIS_FOLLOWUP;
import com.health.viewscontrols.NovaApplication;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 肺结核随访上传接口参数（随访信息）
 *
 * @author wangxiangyi
 * @date 2018/05/05
 */
public class TuberculosisFollowUpInfo {

    /**
     * 症状及体征其他
     */
    private String symptomOther;
    /**
     * 用药_治疗方案
     */
    private String chemotherapy;
    /**
     * 药物不良反应：
     * 无：DM01-11_1，
     * 有：DM01-11_2
     */
    private String drugEffects;
    /**
     * 并发症或合并症：
     * 无：DM01-11_1，
     * 有：DM01-11_2
     */
    private String complication;
    /**
     * 并发症或合并症描述
     */
    private String complicationState;
    /**
     * 转诊科别
     */
    private String transferRegion;
    /**
     * 转诊原因
     */
    private String transferReason;
    /**
     * 2周内随访，随访结果
     */
    private String transferResult;
    /**
     * 实际访视次数
     */
    private String viewTrueNumber;
    /**
     * 实际服药次数
     */
    private String drugTrueNumber;
    /**
     * 目标吸烟量
     */
    private String targetSmoke;
    /**
     * 目标饮酒量
     */
    private String targetDrink;
    /**
     * 药物不良反应
     */
    private String effectsState;
    /**
     * 处理意见
     */
    private String advice;
    /**
     * 创建机构
     */
    private String createorg;
    /**
     * 修改机构
     */
    private String updateorg;
    /**
     * 修改时间
     */
    private String updatetime;
    /**
     * 创建时间
     */
    private String createtime;
    /**
     * 完整度
     */
    private String wzd;
    /**
     * 创建人
     */
    private String creater;
    /**
     * 缺项值
     */
    private String qdqxz;
    /**
     * 修改人
     */
    private String modified;
    /**
     * 随访时间
     */
    private String happentime;
    /**
     * 下次随访时间
     */
    private String nextVisitDate;
    /**
     * 随访方式：
     * 门诊：DM04-15_1，
     * 家庭：DM04-15_2，
     * 电话：DM04-15_3
     */
    private String visitWay;
    /**
     * 吸烟量
     */
    private String smoke;
    /**
     * 饮酒量
     */
    private String drink;
    /**
     * 录入人
     */
    private String inputMan;
    /**
     * 治疗月序
     */
    private String treatMonth;
    /**
     * 督导人员：
     * 医生：DM102-07_1，
     * 家属：DM102-07_2，
     * 自服药：DM102-07_3，
     * 其他：DM102-07_4
     */
    private String supervisor;
    /**
     * 症状及体征:
     * DM102-04_0 没有症状，
     * DM102-04_1 咳嗽咳痰，
     * DM102-04_2 低热盗汗，
     * DM102-04_3 咯血或血痰，
     * DM102-04_4 胸痛消瘦，
     * DM102-04_5 恶心纳差，
     * DM102-04_7 头痛失眠，
     * DM102-04_8 视物模糊，
     * DM102-04_9 皮肤瘙痒、皮疹，
     * DM102-04_10 耳鸣、听力下降
     */
    private String symptom;
    /**
     * 用药_用法：
     * 每日：DM102-05_1，
     * 间歇：DM102-05_2
     */
    private String drugUseage;
    /**
     * 用药_药品剂型：
     * 固定剂量复合制剂:DM102-06_1，
     * 散装药:DM102-06_2，
     * 板式组合药:DM102-06_3，
     * 注射剂:DM102-06_4
     */
    private String drugType;
    /**
     * 用药_漏服药次数
     */
    private String drugTime;
    /**
     * 出现停止治疗时间
     */
    private String stopTime;
    /**
     * 停止治疗原因：
     * 完成疗程：DM102-09_1，
     * 死亡：DM102-09_2，
     * 丢失：DM102-09_3，
     * 转入耐多药治疗：DM102-09_4
     */
    private String stopReason;
    /**
     * 应访视患者次数
     */
    private String viewNumber;
    /**
     * 应服药次数
     */
    private String drugNumber;
    /**
     * 服药率
     */
    private String drugRate;
    /**
     * 评估医生签名
     */
    private String doctorSign;
    /**
     * 身份证号
     */
    private String cardid;

    public String getSymptomOther() {
        return symptomOther;
    }

    public void setSymptomOther(String symptomOther) {
        this.symptomOther = symptomOther;
    }

    public String getChemotherapy() {
        return chemotherapy;
    }

    public void setChemotherapy(String chemotherapy) {
        this.chemotherapy = chemotherapy;
    }

    public String getDrugEffects() {
        return drugEffects;
    }

    public void setDrugEffects(String drugEffects) {
        this.drugEffects = drugEffects;
    }

    public String getComplication() {
        return complication;
    }

    public void setComplication(String complication) {
        this.complication = complication;
    }

    public String getComplicationState() {
        return complicationState;
    }

    public void setComplicationState(String complicationState) {
        this.complicationState = complicationState;
    }

    public String getTransferRegion() {
        return transferRegion;
    }

    public void setTransferRegion(String transferRegion) {
        this.transferRegion = transferRegion;
    }

    public String getTransferReason() {
        return transferReason;
    }

    public void setTransferReason(String transferReason) {
        this.transferReason = transferReason;
    }

    public String getTransferResult() {
        return transferResult;
    }

    public void setTransferResult(String transferResult) {
        this.transferResult = transferResult;
    }

    public String getViewTrueNumber() {
        return viewTrueNumber;
    }

    public void setViewTrueNumber(String viewTrueNumber) {
        this.viewTrueNumber = viewTrueNumber;
    }

    public String getDrugTrueNumber() {
        return drugTrueNumber;
    }

    public void setDrugTrueNumber(String drugTrueNumber) {
        this.drugTrueNumber = drugTrueNumber;
    }

    public String getTargetSmoke() {
        return targetSmoke;
    }

    public void setTargetSmoke(String targetSmoke) {
        this.targetSmoke = targetSmoke;
    }

    public String getTargetDrink() {
        return targetDrink;
    }

    public void setTargetDrink(String targetDrink) {
        this.targetDrink = targetDrink;
    }

    public String getEffectsState() {
        return effectsState;
    }

    public void setEffectsState(String effectsState) {
        this.effectsState = effectsState;
    }

    public String getAdvice() {
        return advice;
    }

    public void setAdvice(String advice) {
        this.advice = advice;
    }

    public String getCreateorg() {
        return createorg;
    }

    public void setCreateorg(String createorg) {
        this.createorg = createorg;
    }

    public String getUpdateorg() {
        return updateorg;
    }

    public void setUpdateorg(String updateorg) {
        this.updateorg = updateorg;
    }

    public String getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(String updatetime) {
        this.updatetime = updatetime;
    }

    public String getCreatetime() {
        return createtime;
    }

    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }

    public String getWzd() {
        return wzd;
    }

    public void setWzd(String wzd) {
        this.wzd = wzd;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getQdqxz() {
        return qdqxz;
    }

    public void setQdqxz(String qdqxz) {
        this.qdqxz = qdqxz;
    }

    public String getModified() {
        return modified;
    }

    public void setModified(String modified) {
        this.modified = modified;
    }

    public String getHappentime() {
        return happentime;
    }

    public void setHappentime(String happentime) {
        this.happentime = happentime;
    }

    public String getNextVisitDate() {
        return nextVisitDate;
    }

    public void setNextVisitDate(String nextVisitDate) {
        this.nextVisitDate = nextVisitDate;
    }

    public String getVisitWay() {
        return visitWay;
    }

    public void setVisitWay(String visitWay) {
        this.visitWay = visitWay;
    }

    public String getSmoke() {
        return smoke;
    }

    public void setSmoke(String smoke) {
        this.smoke = smoke;
    }

    public String getDrink() {
        return drink;
    }

    public void setDrink(String drink) {
        this.drink = drink;
    }

    public String getInputMan() {
        return inputMan;
    }

    public void setInputMan(String inputMan) {
        this.inputMan = inputMan;
    }

    public String getTreatMonth() {
        return treatMonth;
    }

    public void setTreatMonth(String treatMonth) {
        this.treatMonth = treatMonth;
    }

    public String getSupervisor() {
        return supervisor;
    }

    public void setSupervisor(String supervisor) {
        this.supervisor = supervisor;
    }

    public String getSymptom() {
        return symptom;
    }

    public void setSymptom(String symptom) {
        this.symptom = symptom;
    }

    public String getDrugUseage() {
        return drugUseage;
    }

    public void setDrugUseage(String drugUseage) {
        this.drugUseage = drugUseage;
    }

    public String getDrugType() {
        return drugType;
    }

    public void setDrugType(String drugType) {
        this.drugType = drugType;
    }

    public String getDrugTime() {
        return drugTime;
    }

    public void setDrugTime(String drugTime) {
        this.drugTime = drugTime;
    }

    public String getStopTime() {
        return stopTime;
    }

    public void setStopTime(String stopTime) {
        this.stopTime = stopTime;
    }

    public String getStopReason() {
        return stopReason;
    }

    public void setStopReason(String stopReason) {
        this.stopReason = stopReason;
    }

    public String getViewNumber() {
        return viewNumber;
    }

    public void setViewNumber(String viewNumber) {
        this.viewNumber = viewNumber;
    }

    public String getDrugNumber() {
        return drugNumber;
    }

    public void setDrugNumber(String drugNumber) {
        this.drugNumber = drugNumber;
    }

    public String getDrugRate() {
        return drugRate;
    }

    public void setDrugRate(String drugRate) {
        this.drugRate = drugRate;
    }

    public String getDoctorSign() {
        return doctorSign;
    }

    public void setDoctorSign(String doctorSign) {
        this.doctorSign = doctorSign;
    }

    public String getCardid() {
        return cardid;
    }

    public void setCardid(String cardid) {
        this.cardid = cardid;
    }

    /**
     * 肺结核第一次入户随访上传接口参数（基本信息）
     *
     * @param context 上下文
     * @return
     */
    public static List<TuberculosisFollowUpInfo> convertData(Context context) {
        List<TuberculosisFollowUpInfo> datas = new ArrayList<>();

        FDbManager fdb = FDbManager.getInstance(context);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        if (null == NovaApplication.getUserInfo()) {
            return datas;
        }
        List<CD_TUBERCULOSIS_FOLLOWUP> infos = fdb.findAllByWhere(CD_TUBERCULOSIS_FOLLOWUP.class,
                "CARDID='" + NovaApplication.getUserInfo().getIDCARD() + "'");

        if (infos != null && !infos.isEmpty()) {
            for (CD_TUBERCULOSIS_FOLLOWUP info : infos) {
                TuberculosisFollowUpInfo tuberculosisFollowUpInfo = new TuberculosisFollowUpInfo();
                /*身份证号*/
                tuberculosisFollowUpInfo.setCardid(TextUtils.isEmpty(info.getCARDID()) ? "" : info.getCARDID().toUpperCase());
                if(TextUtils.isEmpty(tuberculosisFollowUpInfo.getCardid())){
                    if(!TextUtils.isEmpty(info.getPERSONALID())){
                        List<ARCHIVE_BASEINFO> ss=FDbManager.getInstance(context).findAllByWhere(ARCHIVE_BASEINFO.class,"ARCHIVEID='"+info.getPERSONALID()+"'");
                        if(ss.size()>0){
                            if(!ss.get(0).getPOPULATION_TYPE().contains("11")){
                                continue;
                            }
                            tuberculosisFollowUpInfo.setCardid(ss.get(0).getIDCARD().toUpperCase());
                        }else{
                            tuberculosisFollowUpInfo.setCardid("");
                        }

                    }
                }else{
                    List<ARCHIVE_BASEINFO> ss=FDbManager.getInstance(context).findAllByWhere(ARCHIVE_BASEINFO.class,"IDCARD='"+info.getCARDID()+"'");
                    if(ss.size()>0){
                        if(!ss.get(0).getPOPULATION_TYPE().contains("11")){
                            continue;
                        }
                    }
                }
                /*缺项值*/
                tuberculosisFollowUpInfo.setQdqxz("");
                /*随访时间*/
                if (info.getHAPPENTIME() != null) {
                    tuberculosisFollowUpInfo.setHappentime(formatter.format(info.getHAPPENTIME()));
                }
                /*治疗月序*/
                tuberculosisFollowUpInfo.setTreatMonth(TextUtils.isEmpty(info.getTREAT_MONTH()) ? "" : info.getTREAT_MONTH());
                /*督导人员*/
                tuberculosisFollowUpInfo.setSupervisor(TextUtils.isEmpty(info.getSUPERVISOR()) ? "" : info.getSUPERVISOR());
                /*随访方式*/
                tuberculosisFollowUpInfo.setVisitWay(TextUtils.isEmpty(info.getVISIT_WAY()) ? "" : info.getVISIT_WAY());
                /*症状及体征*/
                tuberculosisFollowUpInfo.setSymptom(TextUtils.isEmpty(info.getSYMPTOM()) ? "" : info.getSYMPTOM());
                /*症状及体征：其他*/
                tuberculosisFollowUpInfo.setSymptomOther(TextUtils.isEmpty(info.getSYMPTOM_OTHER()) ? "" : info.getSYMPTOM_OTHER());
                /*吸烟：日吸烟量*/
                tuberculosisFollowUpInfo.setSmoke(TextUtils.isEmpty(info.getSMOKE()) ? "" : info.getSMOKE());
                /*吸烟：目标吸烟量*/
                tuberculosisFollowUpInfo.setTargetSmoke(TextUtils.isEmpty(info.getTARGET_SMOKE()) ? "" : info.getTARGET_SMOKE());
                /*饮酒：日饮酒*/
                tuberculosisFollowUpInfo.setDrink(TextUtils.isEmpty(info.getDRINK()) ? "" : info.getDRINK());
                /*饮酒：目标饮酒*/
                tuberculosisFollowUpInfo.setTargetDrink(TextUtils.isEmpty(info.getTARGET_DRINK()) ? "" : info.getTARGET_DRINK());
                /*化疗方案*/
                tuberculosisFollowUpInfo.setChemotherapy(TextUtils.isEmpty(info.getCHEMOTHERAPY()) ? "" : info.getCHEMOTHERAPY());
                /*用法*/
                tuberculosisFollowUpInfo.setDrugUseage(TextUtils.isEmpty(info.getDRUG_USEAGE()) ? "" : info.getDRUG_USEAGE());
                /*药品剂型*/
                tuberculosisFollowUpInfo.setDrugType(TextUtils.isEmpty(info.getDRUG_TYPE()) ? "" : info.getDRUG_TYPE());
                /*漏服药次数*/
                tuberculosisFollowUpInfo.setDrugTime(TextUtils.isEmpty(info.getDRUG_TIME()) ? "" : info.getDRUG_TIME());
                /*药物不良反应*/
                tuberculosisFollowUpInfo.setDrugEffects(TextUtils.isEmpty(info.getDRUG_EFFECTS()) ? "" : info.getDRUG_EFFECTS());
                /*药物不良反应：描述*/
                tuberculosisFollowUpInfo.setEffectsState(TextUtils.isEmpty(info.getEFFECTS_STATE()) ? "" : info.getEFFECTS_STATE());
                /*并发症或合并症*/
                tuberculosisFollowUpInfo.setComplication(TextUtils.isEmpty(info.getCOMPLICATION()) ? "" : info.getCOMPLICATION());
                /*并发症或合并症：描述*/
                tuberculosisFollowUpInfo.setComplicationState(TextUtils.isEmpty(info.getCOMPLICATION_STATE()) ? "" : info.getCOMPLICATION_STATE());
                /*科别*/
                tuberculosisFollowUpInfo.setTransferRegion(TextUtils.isEmpty(info.getTRANSFER_REGION()) ? "" : info.getTRANSFER_REGION());
                /*原因*/
                tuberculosisFollowUpInfo.setTransferReason(TextUtils.isEmpty(info.getTRANSFER_REASON()) ? "" : info.getTRANSFER_REASON());
                /*2周内随访，随访结果*/
                tuberculosisFollowUpInfo.setTransferResult(TextUtils.isEmpty(info.getTRANSFER_RESULT()) ? "" : info.getTRANSFER_RESULT());
                /*处理意见*/
                tuberculosisFollowUpInfo.setAdvice(TextUtils.isEmpty(info.getADVICE()) ? "" : info.getADVICE());
                /*下次随访时间*/
                if (info.getNEXT_VISIT_DATE() != null) {
                    tuberculosisFollowUpInfo.setNextVisitDate(formatter.format(info.getNEXT_VISIT_DATE()));
                }
                /*随访医生签名*/
                tuberculosisFollowUpInfo.setInputMan(TextUtils.isEmpty(info.getINPUT_MAN()) ? "" : info.getINPUT_MAN());
                /*出现停止治疗时间*/
                if (info.getSTOP_TIME() != null) {
                    tuberculosisFollowUpInfo.setStopTime(formatter.format(info.getSTOP_TIME()));
                }
                /*停止治疗原因*/
                tuberculosisFollowUpInfo.setStopReason(TextUtils.isEmpty(info.getSTOP_REASON()) ? "" : info.getSTOP_REASON());
                /*应访视患者次数*/
                tuberculosisFollowUpInfo.setViewNumber(TextUtils.isEmpty(info.getVIEW_NUMBER()) ? "" : info.getVIEW_NUMBER());
                /*实际访视次数*/
                tuberculosisFollowUpInfo.setViewTrueNumber(TextUtils.isEmpty(info.getVIEW_TRUE_NUMBER()) ? "" : info.getVIEW_TRUE_NUMBER());
                /*患者在治疗过程中：应服药次数*/
                tuberculosisFollowUpInfo.setDrugNumber(TextUtils.isEmpty(info.getDRUG_NUMBER()) ? "" : info.getDRUG_NUMBER());
                /*患者在治疗过程中：实际服药次数*/
                tuberculosisFollowUpInfo.setDrugTrueNumber(TextUtils.isEmpty(info.getDRUG_TRUE_NUMBER()) ? "" : info.getDRUG_TRUE_NUMBER());
                /*患者在治疗过程中：服药率*/
                tuberculosisFollowUpInfo.setDrugRate(TextUtils.isEmpty(info.getDRUG_RATE()) ? "" : info.getDRUG_RATE());
                /*评估医生签字*/
                tuberculosisFollowUpInfo.setDoctorSign(TextUtils.isEmpty(info.getDOCTOR_SIGN()) ? "" : info.getDOCTOR_SIGN());
                /*创建人*/
                tuberculosisFollowUpInfo.setCreater(TextUtils.isEmpty(info.getCREATER()) ? "" : info.getCREATER());
                /*创建时间*/
                if (info.getCREATETIME() != null) {
                    tuberculosisFollowUpInfo.setCreatetime(formatter.format(info.getCREATETIME()));
                }
                /*创建机构*/
                tuberculosisFollowUpInfo.setCreateorg(TextUtils.isEmpty(info.getCREATEORG()) ? "" : info.getCREATEORG());
                /*修改人*/
                tuberculosisFollowUpInfo.setModified(TextUtils.isEmpty(info.getMODIFIED()) ? "" : info.getMODIFIED());
                /*修改时间*/
                if (info.getUPDATETIME() != null) {
                    tuberculosisFollowUpInfo.setUpdatetime(formatter.format(info.getUPDATETIME()));
                }
                /*修改机构*/
                tuberculosisFollowUpInfo.setUpdateorg(TextUtils.isEmpty(info.getUPDATEORG()) ? "" : info.getUPDATEORG());
                /*添加list里面*/
                datas.add(tuberculosisFollowUpInfo);
            }
        }
        return datas;
    }
}
